package com.project.controller;

import com.project.bean.SellMonthBean;
import com.project.bean.SellPieBean;
import com.project.service.ISellService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;

@RestController
@RequestMapping("sell")
@Api(tags = "销售统计控制器")
public class SellController {
    @Autowired
    private ISellService service;

    @RequiresPermissions("count:sell")
    @RequestMapping("findByClasz")
    @ApiOperation(value = "分类统计", notes = "分类统计")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "startDate", value = "起始日期"),
            @ApiImplicitParam(name = "endDate", value = "结束日期")
    })
    public List<SellPieBean> findByClasz(LocalDate startDate, LocalDate endDate) {
        return service.findByClasz(startDate, endDate);
    }

    @RequiresPermissions("count:sell")
    @RequestMapping("findByBrandAndClasz")
    @ApiOperation(value = "分类分品牌统计", notes = "分类分品牌统计")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "startDate", value = "起始日期"),
            @ApiImplicitParam(name = "endDate", value = "结束日期")
    })
    public List<SellPieBean> findByBrandAndClasz(LocalDate startDate, LocalDate endDate) {
        return service.findByBrandAndClasz(startDate, endDate);
    }

    @RequiresPermissions("count:monthSell")
    @RequestMapping("findByYear")
    @ApiOperation(value = "查看某一年的销售统计", notes = "查看某一年的销售统计")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "year", value = "年份")
    })
    public List<SellMonthBean> findByYear(String year) {
        return service.findByYear(year);
    }

    @RequiresPermissions("count:monthSell")
    @RequestMapping("findAllYear")
    @ApiOperation(value = "查看销售的每一年", notes = "查看销售的每一年")
    public List<String> findAllYear() {
        return service.findAllYear();
    }

}
